// pages/mine/mine.js
const app = getApp()
Page({
  data: {
    isLogin: false,
    userInfo:'',
    user_info: {},
    isLogin: false,
    waveUrl: 'https://mobile-dj.oss-cn-beijing.aliyuncs.com/static/wave.gif',
    backImgUrl: 'https://mobile-dj.oss-cn-beijing.aliyuncs.com/static/back.png'
  },
  onLoad: function (options) {
    console.log('onload');
    
  },

  onShow() {
    console.log('onshow');
    var id = getApp().globalData.id;
    if (id == null || id == '') {
      this.setData({
        isLogin: false
      })
    } else {
      let user = wx.getStorageSync('user')
      this.setData({
        userInfo:user
      })
      wx.cloud.database().collection('user_info')
        .doc(id)
        .get()
        .then(res => {
          this.setData({
            isLogin: true,
            user_info: res.data
          })
        })
    }
    this.getTabBar().init();
  },

  // 获取用户信息事件
  onGotUserInfo: function (e) {
    wx.navigateTo({
      url: 'login/login',
    })
    // if (e.detail.errMsg == 'getUserInfo:fail auth deny') {
    //   return;
    // }
    // var that = this;
    // wx.showLoading({
    //   title: '正在登录',
    // })
    // // 成功获取 userInfo 后给此页面赋值 
    // var userInfo = e.detail.userInfo;
    // that.setData({
    //   avatarUrl: userInfo.avatarUrl,
    //   nickName: userInfo.nickName
    // })
    // // 保存用户
  }
})